package com.sinosoft.system.primary.biz.imp;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sinosoft.system.primary.biz.SysUserBiz;
import com.sinosoft.system.primary.dao.SysUserDao;
import com.sinosoft.system.primary.entity.SysUser;
import com.sinosoft.system.util.page.Pagenation;

@Service
@Transactional
public class SysUserBizImp implements SysUserBiz{

	private static Logger log = Logger.getLogger(SysUserBizImp.class);
	
	@Autowired
	private SysUserDao sysUserDao;
	
	@Override
	public int insertSysUser(SysUser sysUser) {
		log.info("新增SysUser数据"+sysUser.toString());
		return sysUserDao.insertSysUser(sysUser);
	}

	@Override
	public int updateSysUser(SysUser sysUser) {
		log.info("更新SysUser数据"+sysUser.toString());
		return sysUserDao.updateSysUser(sysUser);
	}

	@Override
	public int deleteSysUser(int id) {
		log.info("删除SysUser数据 id="+id);
		return sysUserDao.deleteSysUser(id);
	}

	@Override
	public SysUser selectSysUser(int id) {
		log.info("根据ID查询SysUser数据 id="+id);
		return sysUserDao.selectSysUser(id);
	}

	@Override
	public SysUser selectSysUser(List<String> queryKeys,List<Object> queryValues) {
		log.info("查询SysUser数据 ");
		return sysUserDao.selectSysUser(queryKeys, queryValues);
	}

	@Override
	public int selectCountSysUser() {
		log.info("查询SysUser数据 总数量");
		return sysUserDao.selectCountSysUser();
	}

	@Override
	public int selectCountSysUser(List<String> queryKeys,List<Object> queryValues) {
		log.info("查询SysUser数据 总数量"+queryKeys.toString());
		return sysUserDao.selectCountSysUser(queryKeys, queryValues);
	}

	@Override
	public List<SysUser> selectLimitSysUser(int start, int size) {
		log.info("查询SysUser数据 limit数量:start="+start+",size="+size);
		return sysUserDao.selectLimitSysUser(start, size);
	}

	@Override
	public List<SysUser> selectLimitSysUser(List<String> queryKeys,List<Object> queryValues,int start, int size) {
		log.info("条件查询SysUser数据数量");
		return sysUserDao.selectLimitSysUser(queryKeys, queryValues, start,  size);
	}

	@Override
	public List<SysUser> selectAllSysUser() {
		log.info("查询所有SysUser数据");
		return sysUserDao.selectAllSysUser();
	}

	@Override
	public List<SysUser> selectAllSysUser(List<String> queryKeys,List<Object> queryValues) {
		log.info("条件查询所有SysUser数据");
		return sysUserDao.selectAllSysUser(queryKeys, queryValues);
	}

	@Override
	public Pagenation selectPageSysUser(Pagenation page) {
		log.info("分页查询所有SysUser数据");
		int start =	page.getStartRow();
		int size = page.getPageSize();
		List<SysUser> rows = sysUserDao.selectLimitSysUser(page.getQueryKeys(), page.getQueryValues(),start,size);
		int total = sysUserDao.selectCountSysUser(page.getQueryKeys(), page.getQueryValues());
		page.setTotal(total);
		page.setRows(rows);
		return page;
	}

	public SysUserDao getSysUserDao() {
		return sysUserDao;
	}

	public void setSysUserDao(SysUserDao sysUserDao) {
		this.sysUserDao = sysUserDao;
	}

}
